# Copyright (c) 2022-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(TOP_DIR ${CMAKE_SOURCE_DIR})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

message(STATUS "top_dir: ${TOP_DIR}")

if (MINGW)
    set(ffmpeg_lib_path ${TOP_DIR}/3rdparty/ffmpeg/windows/lib)
    set(ffmpeg_inc_path ${TOP_DIR}/3rdparty/ffmpeg/windows/include)
    set(sdl_lib_path ${TOP_DIR}/3rdparty/SDL2.0/windows/lib/x64)
    set(sdl_inc_path ${TOP_DIR}/3rdparty/SDL2.0/include)
    set(curl_lib_path ${TOP_DIR}/3rdparty/curl/lib/windows)
    set(gtest_lib_path ${TOP_DIR}/3rdparty/gtest/mingw64/lib)
else ()
    set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++11 -Wall")
    set(ffmpeg_lib_path /usr/local/ffmpeg/lib)
    set(ffmpeg_inc_path /usr/local/ffmpeg/include)
    set(sdl_lib_path /usr/lib/x86_64-linux-gnu/)
    set(sdl_inc_path /usr/include/SDL2)
    set(gtest_lib_path ${TOP_DIR}/3rdparty/gtest/linux/lib)
endif ()

set(CMAKE_VERBOSE_MAKEFILE ON)

include_directories(
        ${ffmpeg_inc_path}
        ${sdl_inc_path}
        ${PLAYER_INTERFACE_DIR}
        ${TOP_DIR}/histreamer/engine
        ${TOP_DIR}/3rdparty/gtest/include
        ${TOP_DIR}/3rdparty/ohos
)

file(GLOB SYSTEM_TESTS_SRCS ${TOP_DIR}/demo/system_tests/*.cpp)

set(SRCS
        ${HISTREAMER_SRCS}
        ${3RDPARTY_SRCS}
        )

message(STATUS "${gtest_lib_path}")
link_directories(
        ${ffmpeg_lib_path}
        ${sdl_lib_path}
        ${curl_lib_path}
        ${gtest_lib_path}
)

message(STATUS "Windows demo OHOS_LITE is ${OHOS_LITE}")
if (${OHOS_LITE})
    add_definitions(-DOHOS_LITE)

    # only for lite stream source player
    file(GLOB OSAL_THREAD_SRCS ${TOP_DIR}/histreamer/engine/foundation/osal/thread/*.cpp)
    set(SRCS
            ${SRCS}
            ${OSAL_THREAD_SRCS}
            ${TOP_DIR}/histreamer/engine/foundation/osal/utils/util.cpp
            ${TOP_DIR}/histreamer/engine/scene/common/data_stream.cpp
            ${TOP_DIR}/histreamer/engine/scene/common/data_stream_impl.cpp
            )
endif ()

link_libraries(
    histreamer
    gtest
)

add_executable(histreamer_system_tests ${SRCS} ${SYSTEM_TESTS_SRCS})
